Skip to content

fix(sync): re-export edited observations by checking UpdatedAt#450

Merged
Alan-TheGentleman merged 1 commit into
mainfrom
fix/sync-reexport-edited-447
May 29, 2026
Merged

fix(sync): re-export edited observations by checking UpdatedAt#450
Alan-TheGentleman merged 1 commit into
mainfrom
fix/sync-reexport-edited-447

Conversation

@Alan-TheGentleman
Copy link
Copy Markdown
Collaborator

Summary

Closes #447 — after mem_update edits an observation in place, engram sync reported "Nothing new to sync" and the chunk kept the stale content. Edited observations were never re-exported.

Root cause

filterNewData (internal/sync/sync.go) selected observations by CreatedAt > cutoff only. Edited rows have UpdatedAt > CreatedAt but unchanged CreatedAt, so they were filtered out.

Change

One-line fix: include observations where CreatedAt or UpdatedAt is after the cutoff. UpdatedAt is already populated on store.Observation and in the export path. Content-hash dedup (chunkcodec.ChunkID) prevents redundant chunks on no-op re-syncs.

Test plan

TDD red→green. New TestFilterNewDataIncludesEditedObservations: an observation with CreatedAt before cutoff and UpdatedAt after cutoff is now included; never-edited rows stay excluded (no false inclusion). go test ./internal/sync/... and go build ./... clean.

Notes

Passed adversarial review (UpdatedAt always populated via NOT NULL DEFAULT; no over-export risk; import round-trip upserts by sync_id).

…terNewData (#447)

Observations edited via mem_update have UpdatedAt > CreatedAt but unchanged
CreatedAt, so the previous cutoff check (CreatedAt only) silently dropped them
from every subsequent sync. Include the observation when either CreatedAt or
UpdatedAt is after the cutoff so edits are always re-exported.
Copilot AI review requested due to automatic review settings May 29, 2026 12:15
@Alan-TheGentleman Alan-TheGentleman added the type:bug Bug fix label May 29, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes issue #447 where engram sync failed to re-export observations edited in place via mem_update. The local chunk export path's filterNewData only selected observations with CreatedAt > cutoff, ignoring edited rows whose UpdatedAt was bumped but whose CreatedAt remained unchanged. The one-line fix also checks UpdatedAt, so edited observations now flow back into newly generated chunks (with content-hash dedup preventing redundant chunks on true no-ops).

Changes:

  • Extend filterNewData observation filter to include rows where either CreatedAt or UpdatedAt exceeds the cutoff.
  • Add TestFilterNewDataIncludesEditedObservations covering edited, unedited, and newly created cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/sync/sync.go One-line change to also include observations whose UpdatedAt is past the cutoff
internal/sync/sync_test.go New TDD test verifying edited observations are re-exported while never-edited stale rows remain excluded

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Alan-TheGentleman Alan-TheGentleman merged commit b1f96d4 into main May 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(sync): local chunk sync never re-exports edited observations (mem_update) — silent "Nothing new to sync"

2 participants